import http from '@/utils/http'
// 得到文章列表数据
export const getArticleLists = params => {
  console.log(123)
  return http({
    method: 'GET',
    url: 'app/v1_1/articles',
    params: params
  })
}
// 得到文章详情数据
export const getParticularsData = articleId => {
  return http({
    method: 'GET',
    url: `/app/v1_0/articles/${articleId}`
  })
}
// 添加关注
export const addAttention = userId => {
  return http({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}
// 取消关注
export const cancelAttention = userId => {
  return http({
    method: 'DELETE',
    url: `/app/v1_0/user/followings/${userId}`
  })
}
/**
 * 收藏文章
 */
export const addCollect = target => {
  return http({
    method: 'POST',
    url: '/app/v1_0/article/collections',
    data: {
      target
    }
  })
}

/**
 * 取消收藏文章
 */
export const deleteCollect = target => {
  return http({
    method: 'DELETE',
    url: `/app/v1_0/article/collections/${target}`
  })
}
/**
 * 点赞
 */
export const addLike = articleId => {
  return http({
    method: 'POST',
    url: '/app/v1_0/article/likings',
    data: {
      target: articleId
    }
  })
}

/**
 * 取消点赞
 */
export const deleteLike = articleId => {
  return http({
    method: 'DELETE',
    url: `/app/v1_0/article/likings/${articleId}`
  })
}
/**
 * 获取评论或评论回复
 */
export const conmentArticle = params => {
  return http({
    method: 'GET',
    url: '/app/v1_0/comments',
    params
  })
}
/**
 * 发送评论
 */
export const addComments = datas => {
  return http({
    method: 'POST',
    url: '/app/v1_0/comments',
    data: {
      ...datas
    }
  })
}
/**
 * 获取指定用户信息
 */
export const getUserById = userId => {
  return http({
    method: 'GET',
    url: `/app/v1_0/users/${userId}`
  })
}
/** * 获取指定用户的文章列表 */
export const getArticlesByUser = (userId, params) => {
  return http({
    method: 'GET',
    url: `/app/v1_0/users/${userId}/articles`,
    params
  })
}
